﻿@using Kojarskiy.Core
@{
    var context = new Kojarskiy.Models.KojarskiyDbEntities();
    IQueryable<Kojarskiy.Models.SiteMap> mainMenu = null;
    switch (Kojarskiy.Core.Localization.Current)
    {
        case "Ru-ru":
            mainMenu = context.SiteMap.Where(x => x.ParentId == 1 && x.Show || x.SiteMapId == 1).OrderBy(x => x.Order);
            break;
        case "En-us":
            mainMenu = context.SiteMap.Where(x => x.ParentId == 160 && x.Show || x.SiteMapId == 160).OrderBy(x => x.Order);
            break;
        case "Ua-ua":
            mainMenu = context.SiteMap.Where(x => x.ParentId == 166 && x.Show || x.SiteMapId == 166).OrderBy(x => x.Order);
            break;
    }
    
    var page = Request.Params["page"];
    if (string.IsNullOrEmpty(page)){ page = "/";}
}
<div id="menu">
    <ul>
        @{ 
            int i = mainMenu.Count();
            foreach (var node in mainMenu)
            {
                if (page == node.Path)
                {
                <li>
                    <a href="@Url.Action(node.Action,node.Controller, new {page = node.Path})" class="current">
                        @node.PageName
                    </a>
                </li>
                }
                else
                {
                <li>
                    <a href="@Url.Action(node.Action,node.Controller, new {page = node.Path})">
                        @node.PageName
                    </a>
                </li>
                }
                if (i != 1)
                {
                    i--;
                    <li><img src="@Url.Content("~/Content/Images/menu-divider.png")"/></li>
                }
            }
        }
    </ul>   
    @using (Html.BeginForm("Search", "Home", FormMethod.Get, new { @class = "form-inline" }))
    {
        <div class="f_r" style="margin-top: 4px; width: 300px;"><input type="text"  name="searchString" id="searchString" class="form-control" style="height: 29px; font-size: 12px; width: 200px; display: inline;" placeholder="@Localization.GetLocalizedValue("SEARCH")"/> <input type="submit" style=" margin-bottom: 2px;" class="btn btn-success btn-sm" value="@Localization.GetLocalizedValue("SEARCH")"/></div>         
    }
</div>